package com.example.tests;

import static org.junit.Assert.*;

import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.example.tests.logic.AlertHelper;
import com.example.tests.logic.User;
import com.example.tests.pages.LoginPage;
import factories.MyPageFactory;
import factories.WebDriverFactory;

public abstract class Browser {
	protected WebDriver driver;
	protected static WebDriverWait wait;
	public static String baseUrl;
	protected AlertHelper alertHelper;
	public static User admin;
	
	@Before
	public void initBrowserTest() throws MalformedURLException {
		driver = WebDriverFactory.getDriver(null,DesiredCapabilities.firefox());
		wait = new WebDriverWait(driver, 10);
		alertHelper = new AlertHelper(driver);
		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
		baseUrl = "http://localhost/php4dvd";
	    admin = new User("admin","admin@admin.com","admin","Admin");
	    driver.get(baseUrl);
	}
    @Test
	public void testLangChange() {
    	boolean result;
    	result = MyPageFactory.getPage(driver,LoginPage.class)
    				.changeLanguageToNed()
    				.getHeaderText()
    				.matches("Mijn verzameling");
    	assertTrue(result);
    	result = MyPageFactory.getPage(driver,LoginPage.class)
					.changeLanguageToEng()
					.getHeaderText()
					.matches("My collection");
    	assertTrue(result);
	}
}
